﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Util;

namespace UtilLibrary
{
    public abstract class BaseBizEntity
    {
        public BaseBizEntity()
        {
            string[] names = this.GetType().ToString().Split('.');
            this.EntitySetName = DbUtil.ConcatEntityNameSet(names[names.Length - 1].ToLower().Substring(3));
            SetEntityType();
        }
        private int id;

        public int Id
        {
            get { return id; }
            set { id = value; }
        }

        protected Type dataEntityType = null;
        public abstract void SetEntityType();

        public Type GetDataEntityType()
        {
            return dataEntityType;
        }

        public String EntitySetName = String.Empty;

        public void Create()
        {
            DataAccessor.InsertData(this);
        }

        public void Update() {
            DataAccessor.UpdateData(this);
        }

        public void Delete() {
            DataAccessor.DeleteData(this);
        }
    }
}
